import logging
from flask import Flask
from config import Config


def create_app():
    app = Flask(__name__, static_folder='../static', static_url_path='')

    # 配置日志
    handler = logging.FileHandler(Config.LOG_FILE)
    handler.setFormatter(logging.Formatter(Config.LOG_FORMAT))
    app.logger.addHandler(handler)
    app.logger.setLevel(Config.LOG_LEVEL)

    # 注册蓝图
    from app.api.routes import bp as api_bp
    app.register_blueprint(api_bp)

    return app
